package com.itcoon.cloud.framework.mybatis.metahandler;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;

import java.util.List;

public class DelegateMetaObjectHandler implements MetaObjectHandler {

    private final List<AbstractMetaObjectHandler> handlers;

    public DelegateMetaObjectHandler(List<AbstractMetaObjectHandler> handlers) {
        this.handlers = handlers;
    }

    @Override
    public void insertFill(MetaObject metaObject) {
        handlers.stream().sorted().forEach(h->h.insertFill(metaObject));
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        handlers.stream().sorted().forEach(h->h.updateFill(metaObject));
    }
}
